﻿#ifndef PDFUTIL_H
#define PDFUTIL_H

#include <QObject>
#include <QPdfDocument>
#include "pdfimageprovider.h"
#include "datamodel.h"

class PdfUtil: public QObject
{
    Q_OBJECT
public:
    PdfUtil(QObject *parent = nullptr);

    Q_INVOKABLE bool open(QString filename, int width, int height);
    Q_INVOKABLE void clipImg(double x, double y, int len);
    Q_PROPERTY(QString imgMsg MEMBER _imgMsg NOTIFY imgMsgChanged)

    void setImageProvider(PdfImageProvider* p);
    void setDataModel(DataModel* p);

signals:
    void imgMsgChanged();


private:
    std::unique_ptr<QPdfDocument> pPdf;
    QString _imgMsg;
    PdfImageProvider* pImageProvider;
    DataModel* pDataModel;
};

#endif // PDFUTIL_H
